home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / var / lib / python-support / python2.6 / rdflib / sparql / bison / Resource.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  3.3 KB  |  80 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. from rdflib import URIRef, BNode
  5. from Util import ListRedirect
  6. from sets import Set
  7.  
  8. class RDFTerm(object):
  9.     '''
  10.     Common class for RDF terms
  11.     '''
  12.     pass
  13.  
  14.  
  15. class Resource(RDFTerm):
  16.     '''
  17.     Represents a sigle resource in a triple pattern.  It consists of an identifier
  18.     (URIReff or BNode) and a list of rdflib.sparql.bison.Triples.PropertyValue instances
  19.     '''
  20.     
  21.     def __init__(self, identifier = None, propertyValueList = None):
  22.         if not identifier is not None or identifier:
  23.             pass
  24.         self.identifier = BNode()
  25.         if not propertyValueList is not None or propertyValueList:
  26.             pass
  27.         self.propVals = []
  28.  
  29.     
  30.     def __repr__(self):
  31.         if not isinstance(self.identifier, BNode) or '_:' + self.identifier:
  32.             pass
  33.         resId = self.identifier
  34.         if not self.propVals or ' %s' % self.propVals:
  35.             pass
  36.         return '%s%s' % (resId, '')
  37.  
  38.     
  39.     def extractPatterns(self):
  40.         for prop, objs in self.propVals:
  41.             for obj in objs:
  42.                 yield (self.identifier, prop, obj)
  43.             
  44.         
  45.  
  46.  
  47.  
  48. class TwiceReferencedBlankNode(RDFTerm):
  49.     '''
  50.     Represents BNode in triple patterns in this form:
  51.     [ :prop1 :val1 ] :prop2 :val2
  52.     '''
  53.     
  54.     def __init__(self, props1, props2):
  55.         self.identifier = BNode()
  56.         self.propVals = list(Set(props1 + props2))
  57.  
  58.  
  59.  
  60. class ParsedCollection(ListRedirect, RDFTerm):
  61.     '''
  62.     An RDF Collection
  63.     '''
  64.     reducable = False
  65.     
  66.     def __init__(self, graphNodeList):
  67.         self.identifier = BNode()
  68.         self.propVals = []
  69.         self._list = graphNodeList
  70.  
  71.     
  72.     def setPropertyValueList(self, propertyValueList):
  73.         self.propVals = propertyValueList
  74.  
  75.     
  76.     def __repr__(self):
  77.         return '<RDF Collection: %s>' % self._list
  78.  
  79.  
  80.